<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li id="foo">foo</li>
        <li id="bar">bar</li>
        <li id="baz">baz</li>
    </ul>
    <div class="box">
        <div class="item">2</div>
        <div class="item">3</div>
        <p>1</p>
    </div>
    <div class="box1">
        <div class="map"></div>
        <div class="item2 map">3</div>
        <div class="item map">2</div>
        <div id="cat"></div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
    <script>
        jQuery(function () {
            console.log(jQuery("li").index());
            console.log(jQuery(".item2").index(".map"));
        })
    </script>
</body>

</html>